diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-12 17:24:13 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 00f147a7a687d5772bcc538bc606cfff972178cd (patch) | |
| tree | 27eabeb83c05e14162c51b69d4a6f36d461947fc /src/pages/article/[slug].tsx | |
| parent | c87c615b5866b8a8f361eeb0764bfdea85740e90 (diff) | |
feat(components): add a Time component
Instead of using helpers functions to format the date each time we need
to use a time element, it makes more sense to create a new component
dedicated to this task.
Diffstat (limited to 'src/pages/article/[slug].tsx')
| -rw-r--r-- | src/pages/article/[slug].tsx | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx index bce493b..dea240f 100644 --- a/src/pages/article/[slug].tsx +++ b/src/pages/article/[slug].tsx @@ -15,6 +15,7 @@ import { Sharing, Spinner, type MetaItemData, + Time, } from '../../components'; import { getAllArticlesSlugs, @@ -26,7 +27,6 @@ import type { Article, NextPageWithLayout, SingleComment } from '../../types'; import { ROUTES } from '../../utils/constants'; import { getBlogSchema, - getFormattedDate, getSchemaJson, getSinglePageSchema, getWebPageSchema, @@ -83,18 +83,6 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ const { content, id, intro, meta, title } = article; const { author, commentsCount, cover, dates, seo, thematics, topics } = meta; - /** - * Retrieve a formatted date (and time). - * - * @param {string} date - A date string. - * @returns {JSX.Element} The formatted date wrapped in a time element. - */ - const getDate = (date: string): JSX.Element => { - const isoDate = new Date(`${date}`).toISOString(); - - return <time dateTime={isoDate}>{getFormattedDate(date)}</time>; - }; - const headerMeta: (MetaItemData | undefined)[] = [ author ? { @@ -114,7 +102,7 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ description: 'ArticlePage: publication date label', id: 'RecdwX', }), - value: getDate(dates.publication), + value: <Time date={dates.publication} />, }, dates.update && dates.publication !== dates.update ? { @@ -124,7 +112,7 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({ description: 'ArticlePage: update date label', id: 'ZAqGZ6', }), - value: getDate(dates.update), + value: <Time date={dates.update} />, } : undefined, { |
